export const formatGoal = (goal) => {
  const goals = {
    'weight_loss': '减脂',
    'muscle_gain': '增肌',
    'health': '健康饮食'
  };
  return goals[goal] || goal || '未设定';
};

export const formatRole = (role) => {
  const roles = {
    'user': '普通用户',
    'admin': '管理员'
  };
  return roles[role] || role || '未知角色';
};

export const formatStatus = (status) => {
  const statuses = {
    'active': '活跃',
    'inactive': '非活跃'
  };
  return statuses[status] || status || '未知状态';
};

export const formatActivityLevel = (level) => {
  const levels = {
    1: '久坐不动',
    2: '轻度活动',
    3: '中度活动',
    4: '高度活动',
    5: '极高活动量'
  };
  return levels[level] || level || '未设定';
};

export const formatDateTime = (dateTimeString) => {
  if (!dateTimeString) return 'N/A';
  try {
    const date = new Date(dateTimeString);
    if (isNaN(date.getTime())) {
      return dateTimeString; // Return original if invalid date
    }
    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, '0');
    const day = date.getDate().toString().padStart(2, '0');
    const hours = date.getHours().toString().padStart(2, '0');
    const minutes = date.getMinutes().toString().padStart(2, '0');
    return `${year}年${month}月${day}日 ${hours}:${minutes}`;
  } catch (error) {
    console.error("Error formatting date:", error);
    return dateTimeString; // Fallback to original string in case of error
  }
}; 